package com.sap.sap_mangers.controller;

import com.sap.sap_mangers.until.SimpleJson;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 樊东升
 * @date 2022/8/5 12:09
 */
@RestController
@RequestMapping("/Test")
public class TestController {
    @PostMapping("/addTaskForWeek")
    public SimpleJson addTaskForWeek(HttpServletRequest request) {
        MultipartHttpServletRequest params = ((MultipartHttpServletRequest) request);
        List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("files");
        String context = params.getParameter("content");
        System.out.println(context);
        for (MultipartFile file : files) {

        }

        return SimpleJson.SUCCESS;
    }

    @PostMapping("/addTaskForWeekParam")
    public SimpleJson addTaskForWeekParam(@RequestParam("context") String context, @RequestParam("file") MultipartFile file, @RequestParam("image") MultipartFile image) {
        System.out.println(context);
        System.out.println(file.getOriginalFilename());
        System.out.println(image.getOriginalFilename());
        return SimpleJson.SUCCESS;
    }

    @GetMapping("/test")
    public SimpleJson test() {
        return SimpleJson.FAILURE;
    }
}
